<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>个人中心</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css" />
		<link rel="stylesheet" href="style/css/agent_my.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/md5.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
		<script src="style/js/jquery.form.js"></script>
	</head>

	<body>
		<div id="agent_my">
		    <div class="top_bg">
				<div>
					<a href="javascript:;" id="per"><span class="setting"></span></a>
				</div>
				<div class="info">
					
					<form id="form1" target="nm_iframe" action="" method="post" enctype="multipart/form-data"> 
						<img id="headImg">
					    <input type="file" id="upload" style="display:none" name="head"/>	
					    <input type="submit" id="sub" style="display: none;"/>
					</form>
					<iframe id="id_iframe" name="nm_iframe" frameborder="0" style="display: none;"></iframe> 
					<span id="uname"></span>
				</div>
			</div>
			<div class="order">
				<div class="block-title">
					<i class="block-title-icon myorder"></i> 我的订单
					<a href="javscript:;" class="block-title-nav allorder">
						<span>查看我的全部订单</span>
					</a>
				</div>
				<div class="block-content">
					<a  href="javascript:;" id="pay">
						<i class="unpaid"></i>
						<span>待付款</span>
					</a>
					<a href="javascript:;" id="stor">
						<i class="unwarnhouse"></i>
						<span>已入库</span>
					</a>
					<a href="javascript:;" id="writeOff">
						<i class="uncancel"></i>
						<span>待核销</span>
					</a>
				</div>
			</div>
			<!--list-->
			<div class="listli">
				<ul>
					<li>
						<a href="javascript:;" class="message">我的消息</a>
					</li>
					<!--<li>
						<a href="cart_list.html" class="cart">购物车</a>
					</li>-->
					<li>
						<a href="javascript:;" class="address">我的地址</a>
					</li>
					<li>
						<a href="javascript:;" class="recommend">工单管理</a>
					</li>
					<li>
						<a href="javascript:;" class="intergral">积分明细</a>
					</li>
					<li>
						<a href="javascript:;" class="intergral_order">积分订单</a>
					</li>
					<li>
						<a href="javascript:;" class="service">联系客服</a>
					</li>
				</ul>
			</div>
	
			<!--footer-->
			<div class="footer" id="footer">
				<ul class="clearfix">
					<li>
						<a href='agent_index.html' target="_blank"><i class="icon_home"></i><span>首页</span></a>
					</li>
					<li>
						<a href="product.html" target="_blank"><i class="icon_mall"></i><span>商城</span></a>
					</li>
					<li>
						<a href='integral_mall.html' target="_blank"><i class="icon_integral"></i><span>积分</span></a>
					</li>
					<li>
						<a href='agent_my.html' target="_blank"><i class="icon_my"></i><span class="active_color">我的</span></a>
					</li>
				</ul>
			</div>	
		</div> 
		<script>
			mui.plusReady(function(){
				var per=document.getElementById("per");
				var headImg=document.getElementById("headImg");
				var uname=document.getElementById("uname");
				var allorder=document.getElementsByClassName("allorder")[0]
				var pay=document.getElementById("pay");
				var stor=document.getElementById("stor");
				var writeOff=document.getElementById("writeOff");
				var message=document.getElementsByClassName("message")[0];
				var setting=document.getElementsByClassName("setting")[0];
				var intergral=document.getElementsByClassName("intergral")[0]
				var service=document.getElementsByClassName("service")[0];
				var recommend=document.getElementsByClassName("recommend")[0]
				var intergralOrder=document.getElementsByClassName("intergral_order")[0]
				var address=document.getElementsByClassName("address")[0]
				var ticket=localStorage.getItem("tick")
                var sign=localStorage.getItem("sig")
				mui.ajax(domain+"/member/getInfo?t="+ticket+"&sign="+sign,{//请求用户信息
					dataType:"json",
					type:'post',
					timeout:10000,
					success:function(data){
						console.log(data)
						if(data.code==1){
							headImg.src=domain2+data.data.head;
							uname.innerHTML=data.data.nickname
						} 
					}
				})
				$("#form1").attr("action",domain+"/member/changeHead?t="+ticket+"&sign="+sign)
				    $("#headImg").click(function() {
				        $("#upload").click(); //隐藏了input:file样式后，点击头像就可以本地上传
				        $("#upload").on("change", function() {
				            var objUrl = getObjectURL(this.files[0]); //获取图片的路径，该路径不是图片在本地的路径
				            if (objUrl) {
				                $("#headImg").attr("src", objUrl); //将图片路径存入src中，显示出图片
				                upimg();
				                $("#sub").click() 
				            }
				        }); 
				    });

				
				  //建立一?可存取到?file的url
				    function getObjectURL(file) {
				        var url = null;
				        if (window.createObjectURL != undefined) { // basic
				            url = window.createObjectURL(file);
				        } else if (window.URL != undefined) { // mozilla(firefox)
				            url = window.URL.createObjectURL(file);
				        } else if (window.webkitURL != undefined) { // webkit or chrome
				            url = window.webkitURL.createObjectURL(file);
				        }  
				        return url;
				    }
				  //上传头像到服务器
				    function upimg() { 
//				        console.log(344)
//				        var pic = $('#upload')[0].files[0];
//				        console.log(pic)
//				        var file = new FormData();
//				        file.append('image', pic); 
//				        console.log(file.append)
                        $("#sub").click(function(){
                        	$("#form1").ajaxSubmit(function(data){
							  console.log(data) 
							  mui.toast(data.msg)
						    })
                        })
				        
				    }
				//页面跳转，参数一：触发事件的元素、参数二：要跳转的页面，参数三：页面跳转传的参数
				jumporder(allorder,"agent_order.html",-99)
				jumporder(pay,"agent_order.html",0) 
				jumporder(stor,"agent_order.html",2)
				jumporder(writeOff,"agent_order.html",3)
				jumporder(message,"message.html","")
				jumporder(recommend,"agent_recommend_mage.html","")
				jumporder(intergral,"integral_subsidiary.html","")
				jumporder(intergralOrder,"integral_order.html","")
				jumporder(address,"address.html","")
				jumporder(service,"contact_service.html","")
				jumporder(setting,"personal_data.html","")
				//jumporder(service)
			})
		</script>
	</body>

</html>